package com.ninthgroup.controller;

import com.ninthgroup.entity.TechnicalOffice;
import com.ninthgroup.service.TechnicalOfficeService;
import com.ninthgroup.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author ：Student A Wei
 * @date ：Created in 2022/10/18 16:31
 * @description：科室管理的控制层
 * @modified By：
 * @version:
 */
@RestController
@RequestMapping("/TechnicalOffice")
public class TechnicalOfficeController {
    @Autowired
    private TechnicalOfficeService technicalOfficeService;

    @RequestMapping("/select")
    public Result select(
            @RequestParam(defaultValue = "1") Integer currentPage,
            @RequestParam(defaultValue = "5") Integer pageSize,
            @RequestBody TechnicalOffice technicalOffice){
        return technicalOfficeService.selectAll(currentPage, pageSize,technicalOffice.gettName(),technicalOffice.gettStatus());
    }

    //删除科室
    @RequestMapping("/delete")
    public Result delete(Integer tId) {
        return technicalOfficeService.deleteByTechnicalOfficeId(tId);
    }

    // 添加科室
    @RequestMapping("/add")
    @ResponseBody
    public Result add(@RequestBody TechnicalOffice technicalOffice) {
        return technicalOfficeService.insertAdd(technicalOffice);
    }

    //修改科室表
    @RequestMapping("/update")
    @ResponseBody
    public Result update(@RequestBody TechnicalOffice technicalOffice) {
        return technicalOfficeService.update(technicalOffice);
    }



    @GetMapping("/updateStatus")
    public Result updateStatus(Integer tId, Integer tStatus){
        return technicalOfficeService.updateStatus(tId,tStatus);
    }

}
